﻿using System;
using System.Text;

namespace dotHTML.HTML {
    /// <summary>
    /// Represents a scalar value.
    /// </summary>
    [Serializable]
    public class Meter : Element {
        private float? _value;
        private float? _min;
        private float? _max;
        private float? _low;
        private float? _high;
        private float? _optimum;
        private Form _form;

        /// <summary>
        /// Determines the current value of this meter.
        /// </summary>
        public float? Value {
            get { return _value; }
            set { _value = value; }
        }

        /// <summary>
        /// Determines the minimum value of this meter.
        /// </summary>
        public float? Min {
            get { return _min; }
            set { _min = value; }
        }

        /// <summary>
        /// Determines the maximum value of this meter.
        /// </summary>
        public float? Max {
            get { return _max; }
            set { _max = value; }
        }

        /// <summary>
        /// Determines a low value threshold for this meter.
        /// </summary>
        public float? Low {
            get { return _low; }
            set { _low = value; }
        }

        /// <summary>
        /// Determines a high value threshold for this meter.
        /// </summary>
        public float? High {
            get { return _high; }
            set { _high = value; }
        }

        /// <summary>
        /// Determines the optimum value of this meter.
        /// </summary>
        public float? Optimum {
            get { return _optimum; }
            set { _optimum = value; }
        }

        /// <summary>
        /// Determines the parent form of this meter.
        /// </summary>
        public Form Form {
            get { return _form; }
            set { _form = value; }
        }

        /// <summary>
        /// Gets a formatted string of all child elements of this element.
        /// </summary>
        /// <param name="sb">The StringBuilder to write this element's child
        /// data to.</param>
        protected override void WriteLocalAttributes(StringBuilder sb) {
            if(_form != null) AttributeWriter.Write(sb, _form.ID, "form");
            AttributeWriter.Write(sb, _high, "high");
            AttributeWriter.Write(sb, _low, "low");
            AttributeWriter.Write(sb, _max, "max");
            AttributeWriter.Write(sb, _min, "min");
            AttributeWriter.Write(sb, _optimum, "optimum");
            AttributeWriter.Write(sb, _value, "value");
        }
    }
}
